﻿<html>
<head><title>.:: VNews - Tin tức tận tay ::.</title>
<link rel="stylesheet" type="text/css" href="css/style.css" />
<script type="text/javascript" src="jquery/jquery-1.8.1.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="Content-Language" content="UTF-8" />
<meta name="viewport" content="width=320; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta names="apple-mobile-web-app-status-bar-style" content="black-translucent" />
	<script language="javascript">
		jQuery.ajax({
				url:"http://buminta.pro/Vnews/service/login.php",
				xhrFields: {
				withCredentials: true
				},
				success: function (data){
					console.log(data);
					var user_info = JSON.parse(data);
					console.log(user_info);
					if(user_info==''||user_info.result.status!=true){
					alert('Bạn chưa đăng nhập');
					$(window.location).attr('href', 'login.htm');
					}
				}
			});
		function getCookie(c_name)
			{
			var i,x,y,ARRcookies=document.cookie.split(";");
			for (i=0;i<ARRcookies.length;i++)
			{
			  x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
			  y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
			  x=x.replace(/^\s+|\s+$/g,"");
			  if (x==c_name)
			    {
			    return unescape(y);
			    }
			  }
			}
		$(document).ready(function(){
			var id = getCookie('id');
			console.log(id);
			var catalog;
			if(id!=null){
				var catalog = id[0]+id[1];
			}
			else{
				id = "DF00";
			}
			var xml;
			switch(catalog){
				case 'VH': xml='http://buminta.pro/Vnews/data/RSS.xml'; break;
				case 'TG': xml='http://buminta.pro/Vnews/data/RSS.xml'; break;
				case 'XH': xml='http://buminta.pro/Vnews/data/RSS.xml'; break;
				case 'TT': xml='http://buminta.pro/Vnews/data/RSS.xml'; break;
				case 'KD': xml='http://buminta.pro/Vnews/data/RSS.xml'; break;
				case 'PL': xml='http://buminta.pro/Vnews/data/RSS.xml'; break;
				default: xml='http://buminta.pro/Vnews/data/Default.xml'; break;
			}
			console.log(xml);
			jQuery.ajax({
				url:xml,
				xhrFields: {
				withCredentials: true
				},
				success: function (xml){
					$(xml).find('item').each( function(){
						var itemID = $(this).find('iD').text();
						if (itemID == id){
							var title = $(this).find('title').text();
							var content = $(this).find('description').text();
							var img = $(this).find('link').text();
							$('#footer').append('<div class="title">'+title+'</div>');
							$('#center').append('<div class="content"><p align="center"><img width="200" src="'+img+'"></p>'+content+'</div>');
						}
					})
				}
			});
		})
	</script>
</head>
<body>
	<div id="footer">
		<input type="image" src="images/backBtn.png" class="backBtn" onClick="history.go(-1)">
	</div>
	<div id="center">
	</div>
</body>
</html>
